What's the best performance library for loading images in PNG?
What's the best performance library for loading images in PNG?
Last edited by barracuda; 01-29-2015 at 08:56 AM.
EDIT: Hm, fail by me. I must have written my answer in the wrong thread. Sorry for the noise.
EDIT2: Not fail by me, fail by the OP by reusing another thread to create a new thread.
EDIT3: This thread is now in the wrong sub forum, could somebody move it?
Last edited by Jimmy; 01-29-2015 at 09:10 AM.
As far as I'm aware, libpng (which uses zlib for the actual compression) is not only the reference implementation, but is also the fastest portable one, too. There might be some special-purpose, limited-feature or limited-architecture implementations, but I would not expect them to have any significant speed boost.
The compression used in PNG files is straightforward data compression. It uses the DEFLATE algorithm (Lempel-Ziv with Huffman encoding), the exact same as used for Java JAR archives (and lots of places elsewhere too), and was "standardized" two decades ago, in 1996, as RFC 1951.
To get a faster PNG compressor/decompressor, you need to beat zlib in DEFLATE compression/decompression.
Sure, there are sensational claims like in this Intel paper, which says it can compress a PNG file 4.5x faster than zlib, but if you read the summary, it also tells you ".. by sacrificing the compression a little bit". Heh.
This is not to say you cannot beat zlib, as you certainly can, but that to get such a significant speedup that it would matter for PNG compression/decompression, you either need architecture-specific code, or reduce the compression rate. zlib is open (even for your own commercial projects; no need to disclose your own sources to anyone), as is libpng, so most people won't bother. Not even the commercial folks, just look at Oracle et al. For PNG files, zlib is plenty fast.
Then again, you would have found this all out by yourself, had you bothered to Google a bit.
Last year I found LodePNG. I like it because it was very simple to use, also has nice working examples as far as I remember, but I did not compare LodePNG with libpng so do not know what is faster.
Haven't used or looked at LodePNG, but the comments I found (here, Victor's comment here assuming Mac Image I/O is still based on libpng, and so on) via a quick web search, all say they found it slower than libpng. Also, LodePNG seems to be quite memory-intensive; something you might check if working with large images. (Although computers have lots of memory nowadays, we also have lots of stuff running at the same time.)
OK, thanks. I will try the libpng.